# -*-coding = utf-8 -*-

# @Time: 2021/4/28 12:55
# @Author: bistro
# @File: p633.py
# @Software: PyCharm
# 633. 平方数之和
from math import floor


class Solution:
    def judgeSquareSum(self, c: int) -> bool:
        l = 0
        r = floor(c ** 0.5)
        if r ** 2 == c:
            return True
        print(r)
        while l <= r:
            ans = l ** 2 + r ** 2
            if ans == c:
                return True
            elif ans > c:
                r -= 1
            else:
                l += 1
        return False


s = Solution()
print(s.judgeSquareSum(2147483647))
